get history type of an object

Hi,

For each object, I want to get the "lastmodifiedby" attribute but only for the objects that "AS Suivi" attribute has changed.

Then, I list the username and their counting occurences (by fSkip_Increment function).

There is my code, but it never run the "for h in current OIbject" loop. Is there any mistake that I don't see ?

bool fSkip_Increment(Skip upd_skpList, string KeyValue)
{    // Insert the KeyValue into the Skip list's 'Key'.
        // The 'Data' portion of the Skip is set to 1 for new inserts and is
        //    incremented for already existing 'Key's in the Skip.
        // 'Data' MUST be of type Integer.
        //   (represents the number of references).
        // Return whether this is a first insert for KeyValue into the Skip.
        bool IsNewValue = false
        int NumReferences = 0 // Remains zero if next "find" doesn't find anything:
        if(find(upd_skpList, KeyValue, NumReferences))
                delete(upd_skpList, KeyValue)  // Remove It
        else IsNewValue = true   // Mark it New
                // ReInsert new or updated counts
        NumReferences++
        put (upd_skpList, KeyValue, NumReferences)
        return(IsNewValue)
} // end fSkip_Increment()


    Object o
        int count
        Skip compte_user = createString () // création de la skip list
        int iNbEditeurs = 0
        string sNomEditeur
        
        for o in all m do{
                History h
                print "toto\n"
                for h in current Object do {
                        print "titi \n"
                        HistoryType ht = h.type
                        string exigence = o."AS Exigence"
                        string sEditepar = o."Last Modified By"
                        print h.attrName "\n"
                        if (exigence == "TRUE"){
                                if (ht==modifyObject){
                                        if(h.attrName != "AS Suivi"){
                                                fSkip_Increment (compte_user, sEditepar)
                                        }
                                }
                        }
                }
        }
        for count in compte_user do{
                sEditepar = (string key compte_user)
                print count "\t" sEditepar "\n"
        }

 


Estebell - Thu Jun 26 02:58:12 EDT 2014

Re: get history type of an object
SudarshanRao - Thu Jun 26 03:11:20 EDT 2014

You should be using "for h in o do", since o is used as object in the previous loop.

Using current Object would mean it would iterate through the object which is selected as current, when you ran the script.

Re: get history type of an object
llandale - Thu Jun 26 15:55:53 EDT 2014

Yes, line 29:

  • for h in o do {

I think you want to get the Author of the History, and count how many times that person edit.

  • string Author = h.author
  • fSkip_Increment (compte_user, Author)

-Louie

Re: get history type of an object
Estebell - Fri Oct 10 03:31:17 EDT 2014

llandale - Thu Jun 26 15:55:53 EDT 2014

Yes, line 29:

  • for h in o do {

I think you want to get the Author of the History, and count how many times that person edit.

  • string Author = h.author
  • fSkip_Increment (compte_user, Author)

-Louie

I come back to this topic because I can't have what I want exactly.

When I print the result, it sorts the results in alphabetic order of Autors. 

How to sort the results by (string key compte_user) ?

bool fSkip_Increment(Skip upd_skpList, string KeyValue)
{  
        bool IsNewValue = false
        int NumReferences = 0
        if(find(upd_skpList, KeyValue, NumReferences))
                delete(upd_skpList, KeyValue)
        else IsNewValue = true
        
        NumReferences++
        put (upd_skpList, KeyValue, NumReferences)
        return(IsNewValue)
} // end fSkip_Increment()



Object o
int count
Skip compte_user = createString () // création de la skip list
int iNbEditeurs = 0
string sNomEditeur

for o in all m do{
        History h
                string exigence = o."AS Exigence"
                string sEditepar = o."Last Modified By"
                int i = 0
                if (exigence != null){
                        for h in o do {
                                HistoryType ht = h.type
                                if (ht==modifyObject){
                                        if(h.attrName == "Object Text")
                                        {
                                                i++
                                                if (i>1) continue
                                                else 
                                                        {
                                                    fSkip_Increment (compte_user, sEditepar)
                                                }
                                        }
                                } else continue
                        }
                }
        }

        for count in compte_user do{
                sEditepar = (string key compte_user)
                //print count "\t" sEditepar "\n"
        }

For exemple it prints me :

3   aaa
28  bbb
12  ccc
54  ddd

I'd want

54  ddd
28  bbb
12  ccc
3   aaa

 

Re: get history type of an object
llandale - Fri Oct 10 13:19:58 EDT 2014

Estebell - Fri Oct 10 03:31:17 EDT 2014

I come back to this topic because I can't have what I want exactly.

When I print the result, it sorts the results in alphabetic order of Autors. 

How to sort the results by (string key compte_user) ?

bool fSkip_Increment(Skip upd_skpList, string KeyValue)
{  
        bool IsNewValue = false
        int NumReferences = 0
        if(find(upd_skpList, KeyValue, NumReferences))
                delete(upd_skpList, KeyValue)
        else IsNewValue = true
        
        NumReferences++
        put (upd_skpList, KeyValue, NumReferences)
        return(IsNewValue)
} // end fSkip_Increment()



Object o
int count
Skip compte_user = createString () // création de la skip list
int iNbEditeurs = 0
string sNomEditeur

for o in all m do{
        History h
                string exigence = o."AS Exigence"
                string sEditepar = o."Last Modified By"
                int i = 0
                if (exigence != null){
                        for h in o do {
                                HistoryType ht = h.type
                                if (ht==modifyObject){
                                        if(h.attrName == "Object Text")
                                        {
                                                i++
                                                if (i>1) continue
                                                else 
                                                        {
                                                    fSkip_Increment (compte_user, sEditepar)
                                                }
                                        }
                                } else continue
                        }
                }
        }

        for count in compte_user do{
                sEditepar = (string key compte_user)
                //print count "\t" sEditepar "\n"
        }

For exemple it prints me :

3   aaa
28  bbb
12  ccc
54  ddd

I'd want

54  ddd
28  bbb
12  ccc
3   aaa

 

First off, you are giving credit for every History change to the author who last modified the Object.  Instead get the author of the History inside your history loop:

  • sEditepar = h.author
Now for this question.  You want them listed via activity, most history record counts first.  That can get a little sticky since two users can have the same "count", so "count" cannot be a "Key" of a "Skip".  Here is the outline of a wierd algorithm to do it.  We find the currently highest one in the Skip, print it, remove it from the Skip.  Repeat.
  • string GetHighestCount(Skip in_skp)
  • { // Presume in_skp has a "string" key and an "int" Data; positive or zero
  •  // Find the KEY with the highest data
  •  int iHighest = -1, iCount
  •  string sHighest = ""
  •  for iCount in in_skp do
  •  {  if (iCount > iHighest)
  •     {  sHighest = (string key in_skp)
  •        iHighest = iCount
  •     }
  •  }
  •  return(sHighest)
  • } // end GetHighestCount()
  •  
  •  Done = false
  •  while(!Done)
  •  { 
  •     sHighest = GetHighestCount(skp)
  •     if (null sHighest) then Done = true  // Skip is empty
  •     else
  •     {  get(skp, sHighest, iCount)
  •        delete(skp, sHighest)   // remove this highest entry from the Skip
  •        print iCount "\t" sHighest "\n"
  •     }
  •  }

-Louie